package net.thellium.ddiameter.protocol.dictonary.impl;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import com.google.inject.Singleton;

import net.thellium.ddiameter.protocol.AVPType;
import net.thellium.ddiameter.protocol.AVPDictionary;
@Singleton
public class AVPDictionaryImpl implements AVPDictionary {
	static Map<Long, AVPType> dictionary = new HashMap<Long, AVPType>();
	static Map<Long, AVPType> vendorSpecificDictionary = new HashMap<Long, AVPType>();
	static {
		//DIAMETER BASE PROTOCOL AVPS
		//RFC 3588 
		dictionary.put(85l, AVPType.Unsigned32);
		dictionary.put(483l, AVPType.Enumerated);
		dictionary.put(50l, AVPType.UTF8String);
		dictionary.put(485l, AVPType.Unsigned32);
		dictionary.put(480l, AVPType.Enumerated);
		dictionary.put(44l, AVPType.OctetString);
		dictionary.put(287l, AVPType.Unsigned64);
		dictionary.put(259l, AVPType.Unsigned32);
		dictionary.put(258l, AVPType.Unsigned32);
		dictionary.put(274l, AVPType.Enumerated);
		dictionary.put(291l, AVPType.Unsigned32);
		dictionary.put(276l, AVPType.Unsigned32);
		dictionary.put(277l, AVPType.Enumerated);
		dictionary.put(285l, AVPType.Enumerated);
		dictionary.put(25l,AVPType.OctetString);
		dictionary.put(293l, AVPType.DiameterIdentity);
		dictionary.put(283l, AVPType.DiameterIdentity);
		dictionary.put(273l, AVPType.Enumerated);
		dictionary.put(300l, AVPType.Grouped);
		dictionary.put(281l, AVPType.UTF8String);
		dictionary.put(294l, AVPType.DiameterIdentity);
		dictionary.put(55l,AVPType.Time);
		dictionary.put(297l, AVPType.Grouped);
		dictionary.put(298l, AVPType.Unsigned32);
		dictionary.put(279l, AVPType.Grouped);
		dictionary.put(267l, AVPType.Unsigned32);
		dictionary.put(257l, AVPType.Address);
		dictionary.put(299l, AVPType.Unsigned32);
		dictionary.put(272l, AVPType.Unsigned32);
		dictionary.put(264l, AVPType.DiameterIdentity);
		dictionary.put(296l, AVPType.DiameterIdentity);
		dictionary.put(278l, AVPType.Unsigned32);
		dictionary.put(269l, AVPType.UTF8String);
		dictionary.put(280l, AVPType.DiameterIdentity);
		dictionary.put(284l, AVPType.Grouped);
		dictionary.put(33l, AVPType.OctetString);
		dictionary.put(292l, AVPType.DiameterURI);
		dictionary.put(261l, AVPType.Enumerated);
		dictionary.put(262l, AVPType.Unsigned32);
		dictionary.put(268l, AVPType.Unsigned32);
		dictionary.put(282l, AVPType.DiameterIdentity);
		dictionary.put(263l, AVPType.UTF8String);
		dictionary.put(27l, AVPType.Unsigned32);
		dictionary.put(270l, AVPType.Unsigned32);
		dictionary.put(271l, AVPType.Enumerated);
		dictionary.put(265l, AVPType.Unsigned32);
		dictionary.put(295l, AVPType.Enumerated);
		dictionary.put(1l, AVPType.UTF8String);
		dictionary.put(266l, AVPType.Unsigned32);
		dictionary.put(260l, AVPType.Grouped);
		
		//DCCA AVPS
		
		dictionary.put(411l, AVPType.OctetString);
		dictionary.put(412l, AVPType.Unsigned64);
		dictionary.put(413l, AVPType.Grouped);
		dictionary.put(414l, AVPType.Unsigned64);
		dictionary.put(415l, AVPType.Unsigned32);
		dictionary.put(416l, AVPType.Enumerated);
		dictionary.put(417l, AVPType.Unsigned64);
		dictionary.put(418l, AVPType.Enumerated);
		dictionary.put(419l, AVPType.Unsigned64);
		dictionary.put(420l, AVPType.Unsigned32);
		dictionary.put(421l, AVPType.Unsigned64);
		dictionary.put(454l, AVPType.Enumerated);
		dictionary.put(422l, AVPType.Enumerated);
		dictionary.put(423l, AVPType.Grouped);
		dictionary.put(424l, AVPType.UTF8String);
		dictionary.put(426l, AVPType.Enumerated);
		dictionary.put(427l, AVPType.Enumerated);
		dictionary.put(425l, AVPType.Unsigned32);
		dictionary.put(428l, AVPType.Enumerated);
		dictionary.put(429l, AVPType.Integer32);
		dictionary.put(449l, AVPType.Enumerated);
		dictionary.put(430l, AVPType.Grouped);
		dictionary.put(431l, AVPType.Grouped);
		dictionary.put(453l, AVPType.Unsigned32);
		dictionary.put(457l, AVPType.Grouped);
		dictionary.put(456l, AVPType.Grouped);
		dictionary.put(455l, AVPType.Enumerated);
		dictionary.put(432l, AVPType.Unsigned32);
		dictionary.put(433l, AVPType.Enumerated);
		dictionary.put(434l, AVPType.Grouped);
		dictionary.put(435l, AVPType.UTF8String);
		dictionary.put(436l, AVPType.Enumerated);
		dictionary.put(437l, AVPType.Grouped);
		dictionary.put(438l, AVPType.IPFilterRule);
		dictionary.put(461l, AVPType.UTF8String);
		dictionary.put(439l, AVPType.Unsigned32);
		dictionary.put(440l, AVPType.Grouped);
		dictionary.put(441l, AVPType.Unsigned32);
		dictionary.put(442l, AVPType.OctetString);
		dictionary.put(443l, AVPType.Grouped);
		dictionary.put(444l, AVPType.UTF8String);
		dictionary.put(450l, AVPType.Enumerated);
		dictionary.put(452l, AVPType.Enumerated);
		dictionary.put(451l, AVPType.Time);
		dictionary.put(445l, AVPType.Grouped);
		dictionary.put(446l, AVPType.Grouped);
		dictionary.put(458l, AVPType.Grouped);
		dictionary.put(459l, AVPType.Enumerated);
		dictionary.put(460l, AVPType.OctetString);
		dictionary.put(447l, AVPType.Integer64);
		dictionary.put(448l, AVPType.Unsigned32);


	}
	
	public AVPType getTypeByAvpCode(long code) {
		return dictionary.get(code);
	}
	public AVPType getTypeByAvpCodeAndVendorID(long code, long vendorID) {
		long idx = vendorID << 32 + code;
		return vendorSpecificDictionary.get(idx);
	}

}
